import { defineStore } from "pinia";
import config from "@/config";
import { modal } from "@/plugins"
import { env } from '@/api/system/common'

const useSetStore = defineStore("set", {
  state: () => ({
    baseUrl: config.baseUrl,
		barHright: 50,
		timer: null,
		openTimer: true,
		menuClicks: []
  }),
  actions: {
    // 设置服务器地址
    setBaseUrl(url) {
      this.baseUrl = url
      uni.setStorageSync('tyUrl', url)
    },
		getEnv() {
			return new Promise((resolve, reject) => {
			  env().then((res) => {
			  	// console.log(res)
			  	this.env = res.msg
					resolve(res.msg)
			  	// if (res.msg === 'test') {
			  	// 	uni.setTabBarStyle({
			  	// 		backgroundColor: '#2c9af1'
			  	// 	})
			  	// }
			  }).catch((err) => {
					reject(err)
				})
			})
		}
  },
});

export default useSetStore;
